home *** CD-ROM | disk | FTP | other *** search
/ Workbench Design / WB Collection.iso / workbench werkzeuge / icon tools / forceicon / source / checktooltypes.h next >
C/C++ Source or Header  |  1996-04-07  |  2KB  |  84 lines

  1.  
  2. /**********************************************************************/
  3. /*              Check for tooltypes or commandline args,              */
  4. /*                   returning TRUE for FlushMemory                   */
  5. /**********************************************************************/
  6. #ifdef PREFSRUN
  7. static char *Template = "FLUSH=FLUSHMEMORY/S";
  8. #else
  9. static char *Template = "SNAP=SNAPNOTIFY/N";
  10. #endif
  11. static void CheckToolTypes(struct WBStartup *WBenchMsg)
  12. {
  13.     ObtainSemaphore(&FIconSema->FIconSema);
  14.  
  15.         // Launched from WB ???
  16.  
  17.     if(WBenchMsg)
  18.     {
  19.         struct    DiskObject    *MyDObj;
  20.         struct    WBArg        *MyWBArg;
  21.         BPTR            OldDir;
  22.  
  23.         MyWBArg        = WBenchMsg->sm_ArgList;
  24.  
  25.         OldDir        = CurrentDir(MyWBArg->wa_Lock);
  26.  
  27.         if((MyDObj = GetDiskObjectNew(MyWBArg->wa_Name)))
  28.         {
  29. #ifdef PREFSRUN
  30.             FlushMemory            = (FindToolType(MyDObj->do_ToolTypes, "FLUSHMEMORY") != NULL);
  31. #else
  32.             char    *Tool;
  33.  
  34.             if((Tool = FindToolType(MyDObj->do_ToolTypes, "SNAPNOTIFY")))
  35.             {
  36.                 SnapNotify            = atol(Tool);
  37.  
  38.                 if(SnapNotify < 0 || SnapNotify > 2)
  39.                     SnapNotify    = 2;
  40.             }
  41. #endif
  42.             FreeDiskObject(MyDObj);
  43.         }
  44.  
  45.         CurrentDir(OldDir);
  46.     }
  47.  
  48.         // Check command line
  49.  
  50.     else
  51.     {
  52.         APTR        *Args;
  53.         struct    RDArgs    *MyRDArgs;
  54.  
  55.         if((Args = AllocVec(2 * sizeof(ULONG), MEMF_CLEAR)))
  56.         {
  57.             if((MyRDArgs = ReadArgs(Template, (LONG *)Args, NULL)))
  58.             {
  59. #ifdef PREFSRUN
  60.                 FlushMemory        = (Args[0] != NULL);
  61. #else
  62.                 if(Args[0])
  63.                 {
  64.                     SnapNotify        = *((LONG *)Args[0]);
  65.  
  66.                     if(SnapNotify < 0 || SnapNotify > 2)
  67.                         SnapNotify    = 2;
  68.                 }
  69. #endif
  70.  
  71.                 FreeArgs(MyRDArgs);
  72.             }
  73.             else
  74.                 DisplayError(IoErr(), NULL);
  75.  
  76.             FreeVec(Args);
  77.         }
  78.         else
  79.             DisplayError(ERR_NOMEM, NULL);
  80.     }
  81.  
  82.     ReleaseSemaphore(&FIconSema->FIconSema);
  83. }
  84.